#ifndef BASICIMAGESQUARE_H
#define BASICIMAGESQUARE_H

/*!
 * \file      basicimagesquare.h
 * \brief     Square with an image.
 * \author    Duriez Franck
 * \author    Carton Paul-Henri
 * \version   0.1
 */

#include "square.h"
#include "qsfmlwidget.h"

/*!
 * \class BasicImageSquare
 * \brief Basic Square painted with an image.
 *
 * This Square is painted with the image contained in SQUARE_IMAGE.
 * The destruction delay of this Square is set volontary set twice longer
 * than the other Square one's. This have been done to test and proof the stability
 * of the destruction system.
 *
 * This is an example of Square implementation.
 */
class BasicImageSquare : public Square /*{{{*/
{
/*{{{*/
public:
	/*!
	 * \brief Constructor.
	 * \param displayWidget : where display the square
	 * \param dt : pointer to the infinitesimal part of time
	 * \param image : which image to display
	 *
	 * \warning We suppose in this function that the Image has the good dimension.
	 * \todo Remove the sensibility to the bad dimension problem.
	 */
	BasicImageSquare(QSFMLWidget* displayWidget, float* dt, sf::Image image);
	
	/*!
	 * \brief Constructor.
	 * \param displayWidget : where display the square
	 * \param dt : pointer to the infinitesimal part of time
	 * \param imageFile : file name where find the image to display
	 *
	 * \warning We suppose in this function that the Image has the good dimension.
	 * \todo Remove the sensibility to the bad dimension problem.
	 */
	BasicImageSquare(QSFMLWidget* displayWidget, float* dt, std::string imageFile);

	/*!
	 * \brief Destructor.
	 */
	virtual ~BasicImageSquare();

	/*!
	 * \brief Change the image
	 * \param image : which image to display
	 *
	 * \warning We suppose in this function that the Image has the good dimension.
	 * \todo Remove the sensibility to the bad dimension problem.
	 */
	void setImage(sf::Image image);
	
	/*!
	 * \brief Change the image
	 * \param imageFile : file name where find the image to display
	 *
	 * \warning We suppose in this function that the Image has the good dimension.
	 * \todo Remove the sensibility to the bad dimension problem.
	 */
	void setImage(std::string imageFile);
/*}}}*/

	/************
	 * DRAWABLE *
	 ************/
/*{{{*/
public:
	virtual void draw() const;
	virtual void update();

	// absolute setters
	virtual void setCenter(Vector2f center);
	virtual void setPosition(Vector2f position);
	virtual void setRotation(float angle);

	// relative setters
	virtual void moveCenter(Vector2f dcenter);
	virtual void move(Vector2f dposition);
	virtual void rotate(float dangle);

	// getters
	virtual Vector2f getCenter() const;
	virtual Vector2f getPosition() const;
	virtual float getRotation() const;

	// description
	virtual std::string toString() const;
/*}}}*/

	/**********
	 * ACTION *
	 **********/
/*{{{*/
private:
	void destroyStartingProcess();
	void destroyProcess();
	void destroyStoppingProcess();
/*}}}*/

	/**************
	 * ATTRIBUTES *
	 **************/
/*{{{*/
private:
	sf::String m_count;                  ///< Count displayed on destroy
	sf::Image m_image;                   ///< The image to display
	sf::Sprite m_sprite;                 ///< Sprite of the image to display
	float m_time_elapsed_on_destruction; ///< Timer for destruction
/*}}}*/
}; /*}}}*/

#endif // BASICIMAGESQUARE_H
